import './style.scss';
import { ReactNode } from 'react';
import { notFound } from 'next/navigation';
import { fetchUserProfile } from '@/lib/api/account/profile';
import UserProfileHeader from './_component/UserProfileHeader';

type Props = {
	children: ReactNode;
	params: Promise<{ sid: string }>;
};

export default async function UserProfileLayout({ children, params }: Props)
{
	const { sid } = await params;
	const res = await fetchUserProfile(sid);

	if (!res.success || !res.data) {
		notFound();
	}

	const profile = res.data;

	return (
		<div className="user-profile">
			<UserProfileHeader profile={profile} />
			<div className="user-profile__content">
				{children}
			</div>
		</div>
	);
}